function varargout = mainGUI(varargin)
%MAINGUI M-menu_file for mainGUI.fig
%      MAINGUI, by itself, creates a new MAINGUI or raises the existing
%      singleton*.
%
%      H = MAINGUI returns the handle to a new MAINGUI or the handle to
%      the existing singleton*.
%
%      MAINGUI('Property','Value',...) creates a new MAINGUI using the
%      given property value pairs. Unrecognized properties are passed via
%      varargin to mainGUI_OpeningFcn.  This calling syntax produces a
%      warning when there is an existing singleton*.
%
%      MAINGUI('CALLBACK') and MAINGUI('CALLBACK',hObject,...) call the
%      local function named CALLBACK in MAINGUI.M with the given input
%      arguments.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help mainGUI

% Last Modified by GUIDE v2.5 03-Nov-2011 06:32:01

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @mainGUI_OpeningFcn, ...
                   'gui_OutputFcn',  @mainGUI_OutputFcn, ...
                   'gui_LayoutFcn',  [], ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
   gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT

% --- Executes just before mainGUI is made visible.
function mainGUI_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   unrecognized PropertyName/PropertyValue pairs from the
%            command line (see VARARGIN)

    % Choose default command line output for mainGUI
    handles.output = hObject;

    % Stores image data in handle for sharing among callbacks
    handles.imageStruct.image = 0;
    handles.imageStruct.width = 0;
    handles.imageStruct.height = 0;
    handles.imageStruct.exists = 0;
    
    handles.imageStruct2.image = 0;
    handles.imageStruct2.width = 0;
    handles.imageStruct2.height = 0;
    handles.imageStruct2.exists = 0;
    
    % Stores fft results data
    handles.fftStruct.fftImage = 0;
    handles.fftStruct.module = 0;
    handles.fftStruct.phase = 0;
    handles.fftStruct.real = 0;
    handles.fftStruct.imag = 0;
    handles.fftStruct.exists = 0;
    handles.fftStruct.ifftImage = 0;
    
    handles.fftStruct2.fftImage = 0;
    handles.fftStruct2.module = 0;
    handles.fftStruct2.phase = 0;
    handles.fftStruct2.real = 0;
    handles.fftStruct2.imag = 0;
    handles.fftStruct2.exists = 0;
    handles.fftStruct2.ifftImage = 0;
    
    
    % Update handles structure
    guidata(hObject, handles);

% UIWAIT makes mainGUI wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = mainGUI_OutputFcn(hObject, eventdata, handles)
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
    varargout{1} = handles.output;


% --------------------------------------------------------------------
function menu_file_Callback(hObject, eventdata, handles)
% hObject    handle to menu_file (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function menu_file_open_Callback(hObject, eventdata, handles)
% hObject    handle to menu_file_open (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
    [filename, pathname] = uigetfile({'*.*';'*.JPG';'*.BMP';'*.JPEG';'*.PNG';'*.GIF';'*.PGM';'*.RAW';},'File Selector','tp2/FourierImageAnalyzer/images');
    
    if (filename(1) ~= 0 && pathname(1) ~= 0)
        if (~isempty(filename) && ~isempty(pathname))
            handles.imageStruct.image = imread(strcat(pathname,filename));
            [h,w] = size(handles.imageStruct.image);
            handles.imageStruct.width = w;
            handles.imageStruct.height = h;
            handles.imageStruct.exists = 1;
            handles.fftStruct.exists = 0; % resets fourier status
            guidata(hObject, handles);
            imshow(handles.imageStruct.image);
        end
    end



% --------------------------------------------------------------------
function menu_fourier_Callback(hObject, eventdata, handles)
% hObject    handle to menu_fourier (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function menu_fourier_fft_Callback(hObject, eventdata, handles)
% hObject    handle to menu_fourier_fft (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
    
    fftStruct = doFFT(handles.imageStruct);
    handles.fftStruct = fftStruct;
    guidata(hObject, handles);
    
    imshow(real(fftStruct.fftImage));



% --------------------------------------------------------------------
function menu_fourier_amplitude_Callback(hObject, eventdata, handles)
% hObject    handle to menu_fourier_amplitude (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

if (handles.fftStruct.exists == 0)
    fftStruct = doFFT(handles.imageStruct);
    handles.fftStruct = fftStruct;
    guidata(hObject, handles);
else
    fftStruct = handles.fftStruct;
end

% Dynamic range compression before displaying module
imshow(uint8(dynamicRangeCompression(fftStruct.module)));


% --------------------------------------------------------------------
function menu_fourier_phase_Callback(hObject, eventdata, handles)
% hObject    handle to menu_fourier_phase (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

if (handles.fftStruct.exists == 0)
    fftStruct = doFFT(handles.imageStruct);
    handles.fftStruct = fftStruct;
    guidata(hObject, handles);
else
    fftStruct = handles.fftStruct;
end

% display phase component
imshow(fftStruct.phase);


% --------------------------------------------------------------------
function menu_fourier_ifft_Callback(hObject, eventdata, handles)
% hObject    handle to menu_fourier_ifft (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
if (handles.fftStruct.exists == 0)
    handles.fftStruct = doFFT(handles.imageStruct);
    guidata(hObject, handles);
end

handles.fftStruct.ifftImage = doIFFT(handles.fftStruct);
guidata(hObject, handles);
imshow(uint8(real(handles.fftStruct.ifftImage)));


% --------------------------------------------------------------------
function menu_fourier_customamp_Callback(hObject, eventdata, handles)
% hObject    handle to menu_fourier_customamp (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
if (handles.fftStruct.exists == 0)
    handles.fftStruct = doFFT(handles.imageStruct);
end

module = inputdlg({'Module'},'Module replacement value');
module = str2double(module);

handles.fftStruct = modifyFourierModule(module,handles.fftStruct);
handles.fftStruct.ifftImage = doIFFT(handles.fftStruct);
guidata(hObject, handles);
imshow(uint8(real(dynamicRangeCompression(handles.fftStruct.ifftImage))));


% --------------------------------------------------------------------
function menu_fourier_swap_Callback(hObject, eventdata, handles)
% hObject    handle to menu_fourier_swap (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
[filename, pathname] = uigetfile({'*.jpg;*.JPG;.*jpeg;*.JPEG;*.png;*.PNG;*.gif;*.GIF;*.pgm;*.PGM;*.bmp;*.BMP;*.tiff;*.TIFF','Image Files';  '*.*', 'All Files (*.*)'}, ...
   'Select two images', ...
   'tp2/FourierImageAnalyzer/images', ...
   'MultiSelect', 'on');

[r, c] = size(filename);

if (c == 2)
    handles.imageStruct.image = imread(strcat(pathname,char(filename(1))));
    handles.imageStruct2.image = imread(strcat(pathname,char(filename(2))));
    [h1,w1] = size(handles.imageStruct.image);
    [h2,w2] = size(handles.imageStruct2.image);
    handles.imageStruct.width = w1;
    handles.imageStruct.height = h1;
    handles.imageStruct.exists = 1;
    handles.fftStruct.exists = 0; % resets fourier status
    
    handles.fftStruct = doFFT(handles.imageStruct);
    
    handles.imageStruct2.width = w2;
    handles.imageStruct2.height = h2;
    handles.imageStruct2.exists = 1;
    handles.fftStruct2.exists = 0; % resets fourier status
    
    handles.fftStruct2 = doFFT(handles.imageStruct2);
    
    fftStructs = swapFourierPhases(handles.fftStruct, handles.fftStruct2);
    
    handles.fftStruct = fftStructs(1);
    handles.fftStruct2 = fftStructs(2);
    
    guidata(hObject, handles);
    
    imshow(uint8(real(handles.fftStruct.ifftImage)));
end


% --------------------------------------------------------------------
function menu_filters_Callback(hObject, eventdata, handles)
% hObject    handle to menu_filters (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function menu_filters_lowpass_Callback(hObject, eventdata, handles)
% hObject    handle to menu_filters_lowpass (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles.fftStruct = doFFT(handles.imageStruct);


freq = inputdlg({'Cut Off Frequency'},'Select Frequency Limit');
freq = str2double(freq);

H = lowpassFilter(handles.fftStruct, freq);
handles.fftStruct = applyFilter(handles.fftStruct.fftImage, H);
handles.fftStruct.ifftImage = doIFFT(handles.fftStruct);
guidata(hObject, handles);
imshow(uint8(real(handles.fftStruct.ifftImage)));


% --------------------------------------------------------------------
function menu_filters_highpass_Callback(hObject, eventdata, handles)
% hObject    handle to menu_filters_highpass (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles.fftStruct = doFFT(handles.imageStruct);


freq = inputdlg({'Cut Off Frequency'},'Select Frequency Limit');
freq = str2double(freq);

H = highPassFilter(handles.fftStruct, freq);
handles.fftStruct = applyFilter(handles.fftStruct.fftImage, H);
handles.fftStruct.ifftImage = doIFFT(handles.fftStruct);
guidata(hObject, handles);
imshow(uint8(real(handles.fftStruct.ifftImage)));


% --------------------------------------------------------------------
function menu_filters_lowbutterworth_Callback(hObject, eventdata, handles)
% hObject    handle to menu_filters_lowbutterworth (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles.fftStruct = doFFT(handles.imageStruct);


ret = inputdlg({'Cut Off Frequency','Order'},'Select Frequency threshold And filter order');
freq = str2double(ret(1));
order = str2double(ret(2));

H = butterWorthFilter(handles.fftStruct, freq, order);
handles.fftStruct = applyFilter(handles.fftStruct.fftImage, H);
handles.fftStruct.ifftImage = doIFFT(handles.fftStruct);
guidata(hObject, handles);
imshow(uint8(real(handles.fftStruct.ifftImage)));


% --------------------------------------------------------------------
function menu_filters_lowgaussian_Callback(hObject, eventdata, handles)
% hObject    handle to menu_filters_lowgaussian (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles.fftStruct = doFFT(handles.imageStruct);


sigma = inputdlg({'Std Dev'},'Input Standard Deviation');
sigma = str2double(sigma);

H = gaussianFilter(handles.fftStruct, sigma);
handles.fftStruct = applyFilter(handles.fftStruct.fftImage, H);
handles.fftStruct.ifftImage = doIFFT(handles.fftStruct);
guidata(hObject, handles);
imshow(uint8(real(handles.fftStruct.ifftImage)));


% --------------------------------------------------------------------
function menu_filters_sobel_Callback(hObject, eventdata, handles)
% hObject    handle to menu_filters_sobel (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Converts image to grayscale if needed
isColor = size(size(handles.imageStruct.image),2) > 2;

if (isColor == 1)
    handles.imageStruct.image = rgb2gray(handles.imageStruct.image);
    [h,w] = size(handles.imageStruct.image);
    handles.imageStruct.width = w;
    handles.imageStruct.height = h;
end


handles.fftStruct = doFFTDim(handles.imageStruct.image, size(handles.imageStruct.image,1), size(handles.imageStruct.image,2));
[Hy Hx p q] = sobelFilter(handles.imageStruct);
p = floor((p - handles.imageStruct.height)/2);
q = floor((q - handles.imageStruct.width)/2);
fftStructY = applyFilter(padarray(handles.fftStruct.fftImage,[p q]), Hy);
fftStructX = applyFilter(padarray(handles.fftStruct.fftImage,[p q]), Hx);

ifftImageY = doIFFT(fftStructY);
ifftImageX = doIFFT(fftStructX);


gx = real(ifftImageX);
gy = real(ifftImageY);
g = (gx.^2 + gy.^2).^0.5;

guidata(hObject, handles);
imshow(linearRangeCompression(g));


% --------------------------------------------------------------------
function menu_filters_prewitt_Callback(hObject, eventdata, handles)
% hObject    handle to menu_filters_prewitt (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Converts image to grayscale if needed
isColor = size(size(handles.imageStruct.image),2) > 2;

if (isColor == 1)
    handles.imageStruct.image = rgb2gray(handles.imageStruct.image);
    [h,w] = size(handles.imageStruct.image);
    handles.imageStruct.width = w;
    handles.imageStruct.height = h;
end


handles.fftStruct = doFFTDim(handles.imageStruct.image, size(handles.imageStruct.image,1), size(handles.imageStruct.image,2));
[Hy Hx p q] = prewittFilter(handles.imageStruct);
p = floor((p - handles.imageStruct.height)/2);
q = floor((q - handles.imageStruct.width)/2);
fftStructY = applyFilter(padarray(handles.fftStruct.fftImage,[p q]), Hy);
fftStructX = applyFilter(padarray(handles.fftStruct.fftImage,[p q]), Hx);

ifftImageY = doIFFT(fftStructY);
ifftImageX = doIFFT(fftStructX);


gx = real(ifftImageX);
gy = real(ifftImageY);
g = (gx.^2 + gy.^2).^0.5;

guidata(hObject, handles);
imshow(linearRangeCompression(g));


% --------------------------------------------------------------------
function menu_filters_mean_Callback(hObject, eventdata, handles)
% hObject    handle to menu_filters_mean (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles.fftStruct = doFFT(handles.imageStruct);

[H p q] = meanFilter(handles.imageStruct);
p = floor((p - handles.imageStruct.height)/2);
q = floor((q - handles.imageStruct.width)/2);
handles.fftStruct = applyFilter(padarray(handles.fftStruct.fftImage, [p q]), H);
handles.fftStruct.ifftImage = doIFFT(handles.fftStruct);
guidata(hObject, handles);
imshow(uint8(real(handles.fftStruct.ifftImage)));


% --------------------------------------------------------------------
function menu_filters_highbutterworth_Callback(hObject, eventdata, handles)
% hObject    handle to menu_filters_highbutterworth (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
ret = inputdlg({'Cut Off Frequency','Order'},'Select Frequency threshold And filter order');
freq = str2double(ret(1));
order = str2double(ret(2));

H = highButterWorthFilter(handles.fftStruct, freq, order);
handles.fftStruct = applyFilter(handles.fftStruct.fftImage, H);
handles.fftStruct.ifftImage = doIFFT(handles.fftStruct);
guidata(hObject, handles);
imshow(uint8(real(handles.fftStruct.ifftImage)));


% --------------------------------------------------------------------
function menu_filters_highgaussian_Callback(hObject, eventdata, handles)
% hObject    handle to menu_filters_highgaussian (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
sigma = inputdlg({'Std Dev'},'Input Standard Deviation');
sigma = str2double(sigma);

H = highGaussianFilter(handles.fftStruct, sigma);
handles.fftStruct = applyFilter(handles.fftStruct.fftImage, H);
handles.fftStruct.ifftImage = doIFFT(handles.fftStruct);
guidata(hObject, handles);
imshow(uint8(real(handles.fftStruct.ifftImage)));


% --------------------------------------------------------------------
function menu_filets_osobel_Callback(hObject, eventdata, handles)
% hObject    handle to menu_filets_osobel (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
isColor = size(size(handles.imageStruct.image),2) > 2;

if (isColor == 1)
    handles.imageStruct.image = rgb2gray(handles.imageStruct.image);
    [h,w] = size(handles.imageStruct.image);
    handles.imageStruct.width = w;
    handles.imageStruct.height = h;
end


handles.fftStruct = doFFTDim(handles.imageStruct.image, size(handles.imageStruct.image,1), size(handles.imageStruct.image,2));
[Hy Hx p q] = oppositeSobelFilter(handles.imageStruct);
p = floor((p - handles.imageStruct.height)/2);
q = floor((q - handles.imageStruct.width)/2);
fftStructY = applyFilter(padarray(handles.fftStruct.fftImage,[p q]), Hy);
fftStructX = applyFilter(padarray(handles.fftStruct.fftImage,[p q]), Hx);

ifftImageY = doIFFT(fftStructY);
ifftImageX = doIFFT(fftStructX);


gx = real(ifftImageX);
gy = real(ifftImageY);
g = (gx.^2 + gy.^2).^0.5;

guidata(hObject, handles);
imshow(linearRangeCompression(g));


% --------------------------------------------------------------------
function menu_filets_oprewitt_Callback(hObject, eventdata, handles)
% hObject    handle to menu_filets_oprewitt (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Converts image to grayscale if needed
isColor = size(size(handles.imageStruct.image),2) > 2;

if (isColor == 1)
    handles.imageStruct.image = rgb2gray(handles.imageStruct.image);
    [h,w] = size(handles.imageStruct.image);
    handles.imageStruct.width = w;
    handles.imageStruct.height = h;
end


handles.fftStruct = doFFTDim(handles.imageStruct.image, size(handles.imageStruct.image,1), size(handles.imageStruct.image,2));
[Hy Hx p q] = oppositePrewittFilter(handles.imageStruct);
p = floor((p - handles.imageStruct.height)/2);
q = floor((q - handles.imageStruct.width)/2);
fftStructY = applyFilter(padarray(handles.fftStruct.fftImage,[p q]), Hy);
fftStructX = applyFilter(padarray(handles.fftStruct.fftImage,[p q]), Hx);

ifftImageY = doIFFT(fftStructY);
ifftImageX = doIFFT(fftStructX);


gx = real(ifftImageX);
gy = real(ifftImageY);
g = (gx.^2 + gy.^2).^0.5;

guidata(hObject, handles);
imshow(linearRangeCompression(g));


% --------------------------------------------------------------------
function menu_filters_omean_Callback(hObject, eventdata, handles)
% hObject    handle to menu_filters_omean (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles.fftStruct = doFFT(handles.imageStruct);

[H p q] = oppositeMeanFilter(handles.imageStruct);
p = floor((p - handles.imageStruct.height)/2);
q = floor((q - handles.imageStruct.width)/2);
handles.fftStruct = applyFilter(padarray(handles.fftStruct.fftImage,[p q]), H);
handles.fftStruct.ifftImage = doIFFT(handles.fftStruct);
guidata(hObject, handles);
imshow(uint8(real(handles.fftStruct.ifftImage)));


% --------------------------------------------------------------------
function menu_file_show1_Callback(hObject, eventdata, handles)
% hObject    handle to menu_file_show1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
if (handles.imageStruct.exists == 1)
    imshow(handles.imageStruct.image);
end

% --------------------------------------------------------------------
function menu_file_show2_Callback(hObject, eventdata, handles)
% hObject    handle to menu_file_show2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
if (handles.imageStruct2.exists == 1)
    imshow(handles.imageStruct2.image);
end


% --------------------------------------------------------------------
function menu_fourier_primary_Callback(hObject, eventdata, handles)
% hObject    handle to menu_fourier_primary (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
if (handles.fftStruct.exists == 1)
    imshow(uint8(real(handles.fftStruct.ifftImage)));
end

% --------------------------------------------------------------------
function menu_fourier_secondary_Callback(hObject, eventdata, handles)
% hObject    handle to menu_fourier_secondary (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
if (handles.fftStruct2.exists == 1)
    imshow(uint8(real(handles.fftStruct2.ifftImage)));
end


% --------------------------------------------------------------------
function menu_fourier_swapt_Callback(hObject, eventdata, handles)
% hObject    handle to menu_fourier_swapt (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
if (handles.fftStruct2.exists == 1 && (handles.fftStruct.exists == 1))
    fftStructAux = handles.fftStruct;
    handles.fftStruct = handles.fftStruct2;
    handles.fftStruct2 = fftStructAux;
    guidata(hObject, handles);
end


% --------------------------------------------------------------------
function menu_fourier_lmodule_Callback(hObject, eventdata, handles)
% hObject    handle to menu_fourier_lmodule (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
if (handles.fftStruct.exists == 1)
    [filename, pathname] = uigetfile({'*.*';'*.JPG';'*.BMP';'*.JPEG';'*.PNG';'*.GIF';'*.PGM';'*.RAW';},'File Selector','tp2/FourierImageAnalyzer/images');
    
    if (filename(1) ~= 0 && pathname(1) ~= 0)
        if (~isempty(filename) && ~isempty(pathname))
            handles.fftStruct = loadFourierModule(double(imread(strcat(pathname,filename))), handles.fftStruct);
            guidata(hObject, handles);
        end
    end
end


% --------------------------------------------------------------------
function menu_file_save_Callback(hObject, eventdata, handles)
% hObject    handle to menu_file_save (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
if (handles.fftStruct.exists == 1)
    imsave();
end